public class 数字三角形 {
    public static void main(String[] args) {
        char a = 'D';
        fun(a);
        char b = '5';
        fun(b);
    }

    public static void fun(Character c){
        if(49 <= c && c <= 57){  // 数字
            int N = (int)(c-'1')+1;
            for (int i = 1; i <= N; i++) {
                for (int j = 1; j <= N-i; j++) {
                    System.out.print(" ");
                }
                for (int j = 1; j <= i; j++) {
                    System.out.printf("%c",j+48);
                }
                for (int j = i-1; j >=1; j--) {
                    System.out.printf("%c",j+48);
                }
                System.out.println();
            }
        }
        if(65 <= c && c <= 90){  // 字母
            int N = (int)(c-'A')+1;
            for (int i = 1; i <= N; i++) {
                for (int j = 1; j <= N-i; j++) {
                    System.out.print(" ");
                }
                for (int j = 1; j <= i; j++) {
                    System.out.printf("%c",j+64);
                }
                for (int j = i-1; j >=1; j--) {
                    System.out.printf("%c",j+64);
                }
                System.out.println();
            }
        }
    }
}
